//
//  ZWStatusToolBar.swift
//  ZWWeibo
//
//  Created by flyiron on 16/4/21.
//  Copyright © 2016年 flyiron. All rights reserved.
//

import UIKit

class ZWStatusToolBar: UIView {
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func setupUI(){
    
       let retweetBTN = addButton("转发", imageNamed: "timeline_icon_retweet")
       let commentBTN = addButton("评论", imageNamed: "timeline_icon_comment")
       let unlikeBTN = addButton("转发", imageNamed: "timeline_icon_unlike")
        let sp1 = UIImageView(image: UIImage(named: "timeline_card_bottom_line"))
        let sp2 = UIImageView(image: UIImage(named: "timeline_card_bottom_line"))
        addSubview(sp1);addSubview(sp2)
        
       retweetBTN.snp_makeConstraints { (make) -> Void in
        make.leading.top.bottom.equalTo(self)
//        make.width.equalTo(20)
        make.width.equalTo(commentBTN)
        }
        commentBTN.snp_makeConstraints { (make) -> Void in
            make.leading.equalTo(retweetBTN.snp_trailing)
            make.top.bottom.equalTo(self)
            make.width.equalTo(unlikeBTN)
        }
        unlikeBTN.snp_makeConstraints { (make) -> Void in
            make.leading.equalTo(commentBTN.snp_trailing)
            make.top.trailing.bottom.equalTo(self)
            make.width.equalTo(retweetBTN)
        }
        sp1.snp_makeConstraints { (make) -> Void in
            make.centerX.equalTo(retweetBTN.snp_trailing)
            make.centerY.equalTo(self)
        }
        
        sp2.snp_makeConstraints { (make) -> Void in
            make.centerX.equalTo(commentBTN.snp_trailing)
            make.centerY.equalTo(self)
        }
    }
    
    private func addButton(title:String, imageNamed:String) -> UIButton{
        let button = UIButton()
        
        button.setBackgroundImage(UIImage(named: "timeline_card_bottom_background"), forState: UIControlState.Normal)
        button.setBackgroundImage(UIImage(named: "timeline_card_bottom_background_highlighted"), forState: UIControlState.Highlighted)
        button.setImage(UIImage(named: imageNamed), forState: UIControlState.Normal)
        button.setTitle(title, forState: UIControlState.Normal)
        button.setTitleColor(UIColor.darkGrayColor(), forState: UIControlState.Normal)
        
        addSubview(button)
        return button
    }
}
